-
Notifications
You must be signed in to change notification settings - Fork 750
Implement .as_weak() and .upgrade() for global component instances #9436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
ab2a50a
to
595f2e2
Compare
internal/core/api.rs
Outdated
pub use weak_handle::*; | ||
|
||
/// This trait provides the necessary functionality for allowing creating strongly-referenced | ||
/// clones and conversion into/ a weak pointer for a Global slint component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
into/
?
Did you mean into/from
maybe, or is the /
a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
internal/core/api.rs
Outdated
} | ||
|
||
/// Returns a new GlobalStrong struct, where it's possible to get the global component | ||
/// struct interface. Ff some other instance still |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ff => If
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
internal/core/api.rs
Outdated
if std::thread::current().id() != self.thread { | ||
return None; | ||
} | ||
let coso = T::upgrade_from_weak_inner(&self.inner)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coso?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to 'inner'
/// // now forward the data to the main thread using upgrade_in_event_loop | ||
/// my_app_data_weak.upgrade_in_event_loop(move |my_app_data| my_app_data.set_foo(foo)); | ||
/// }); | ||
/// # thread.join().unwrap(); return; // don't run the event loop in examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. This is docu, not actual example, why the commented-out code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a lot of copy / paste from the same function for Weak - at line 930
d2882a0
to
91264dc
Compare
The idea to make it easier and more convenient to pass a reference to a Slint global instance into a Rust closure / lambda. Fixes slint-ui#9389
The idea to make it easier and more convenient to pass a reference to a Slint global instance into a Rust closure / lambda.
The current implementation works the following way:
Fixes #9389